import request from '@/utils/request';

function getArticleListApi(query) {
    return request({
        method: 'get',
        url: '/article',
        params: query
    })
}

function delArticleApi(articleId) {
    return request({
        method: 'delete',
        url: `/article/${articleId}`
    })
}

function getArticleDetailApi(articleId) {
    return request({
        method: 'get',
        url: `/article/${articleId}`
    })
}

function postArticleApi(newArticle) {
    return request({
        method: 'post',
        url: '/article',
        data: newArticle
    })
}

function putArticleApi(updatedArticle) {
    return request({
        method: 'put',
        url: `/article/${updatedArticle.id}`,
        data: updatedArticle
    })
}

const Article = {
    getArticleListApi,
    delArticleApi,
    getArticleDetailApi,
    postArticleApi,
    putArticleApi
}

export default Article